package com.jkl.controller.menu;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import com.jkl.entity.menu.BsPersonDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.jkl.entity.menu.BsMenu;
import com.jkl.service.menu.inter.BsMenuServiceInterface;

import lombok.extern.slf4j.Slf4j;

/**
 * 
 * <p>
 * 123开放层接口
 * <p>
 * <p>
 * 变更说明：wangjingxiang 2017年12月28日 123 增加新增、更新、删除方法
 * <p>
 * Date:2018年10月01日
 * 
 * @author lin.pf
 * @version 1.0
 */
@RestController
@RequestMapping("jky/menu")
@Slf4j
public class BsMenuControllerV1 {

	@Autowired
	private HttpServletRequest request;

	@Autowired
	private BsMenuServiceInterface bsMenuServiceInterface;

	@GetMapping("/getAllMenu")
	public List<BsMenu> getAllMenu() throws Exception {
		return bsMenuServiceInterface.getAllMenu();
	}
	@GetMapping("/getAllMenuWithTotal")
	public BsMenu getAllMenuWithTotal() throws Exception {

		List<BsMenu> allMenu = bsMenuServiceInterface.getAllMenu();
		BsMenu bsMenu = new BsMenu();
		BsMenu bsMenu1 = bsMenu.setMenu(allMenu);
		bsMenu1.setRowId(1).setMenuName("菜单").setStatus(1);
		return bsMenu1;
	}

	@GetMapping("/getMenuIdByroleId")
	public List<Integer> getMenuIdByroleId(@RequestParam int roleId) throws Exception {
		return bsMenuServiceInterface.getMenuIdByroleId(roleId);
	}

	@PostMapping("/getAllMessage")
	public List<BsPersonDTO> getAllMessage(@RequestParam Integer rowId){
		List<BsPersonDTO> allMessage = bsMenuServiceInterface.getAllMessage(rowId);
		return allMessage;
	}
}